package com.ssi.mrms.dao.mapping;

import com.ssi.mrms.model.RMrmlstModel;
import com.ssi.mrms.model.RMrmownModel;
import com.ssi.mrms.model.RMrmtntModel;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;


public class RoomProfileMapping implements RowMapper<RMrmlstModel> {

    public RMrmlstModel mapRow(ResultSet rs, int line) throws SQLException {
        ResultSetExtractor<RMrmlstModel> extractor = new ResultSetExtractor<RMrmlstModel>() {
            public RMrmlstModel extractData(ResultSet rs) throws SQLException, DataAccessException {
                RMrmlstModel model = new RMrmlstModel();
                model.setRlrmid(rs.getInt("RLRMID"));
                model.setRlsttower(rs.getString("RLSTTOWER"));
                model.setRlstfloor(rs.getString("RLSTFLOOR"));
                model.setRlstunitno(rs.getString("RLSTUNITNO"));
                model.setRlstaddr(rs.getString("RLSTADDR"));
                model.setRlsttype(rs.getString("RLSTTYPE"));
                
                RMrmownModel ownModel = new RMrmownModel();
                ownModel.setRownid(rs.getInt("ROWNID"));
                ownModel.setRownprenm(rs.getString("ROWNPRENM"));
                ownModel.setRownfsenm(rs.getString("ROWNFSENM"));
                ownModel.setRownlsenm(rs.getString("ROWNLSENM"));
                ownModel.setRownprlnm(rs.getString("ROWNPRLNM"));
                ownModel.setRownfslnm(rs.getString("ROWNFSLNM"));
                ownModel.setRownmdenm(rs.getString("ROWNMDENM"));
                ownModel.setRownmdlnm(rs.getString("ROWNMDLNM"));
                ownModel.setRownlslnm(rs.getString("ROWNLSLNM"));
                ownModel.setRownnation(rs.getString("ROWNNATION"));
                ownModel.setRownagt(rs.getString("ROWNAGT"));
                ownModel.setRowntfsdat(rs.getDate("ROWNTFSDAT"));
                ownModel.setRownpassno(rs.getString("ROWNPASSNO"));
                ownModel.setRowntel(rs.getString("ROWNTEL"));
                ownModel.setRowntel2(rs.getString("ROWNTEL2"));
                ownModel.setRownaddr(rs.getString("ROWNADDR"));
                ownModel.setRownemail(rs.getString("ROWNEMAIL"));
                ownModel.setRownstat(rs.getString("ROWNSTAT"));
                ownModel.setRowncreby(rs.getString("ROWNCREBY"));
                ownModel.setRowncredat(rs.getDate("ROWNCREDAT"));
                ownModel.setRownupdby(rs.getString("ROWNUPDBY"));
                ownModel.setRownupddat(rs.getDate("ROWNUPDDAT"));
                model.setOwnModel(ownModel);
                
                RMrmtntModel tntModel = new RMrmtntModel();
                tntModel.setRtntid(rs.getInt("RTNTID"));
                tntModel.setRtntprenm(rs.getString("RTNTPRENM"));
                tntModel.setRtntprlnm(rs.getString("RTNTPRLNM"));
                tntModel.setRtntfsenm(rs.getString("RTNTFSENM"));
                tntModel.setRtntfslnm(rs.getString("RTNTFSLNM"));
                tntModel.setRtntmdenm(rs.getString("RTNTMDENM"));
                tntModel.setRtntmdlnm(rs.getString("RTNTMDLNM"));
                tntModel.setRtntlsenm(rs.getString("RTNTLSENM"));
                tntModel.setRtntlslnm(rs.getString("RTNTLSLNM"));
                tntModel.setRtntnation(rs.getString("RTNTNATION"));
                tntModel.setRtntpassno(rs.getString("RTNTPASSNO"));
                tntModel.setRtnttfsdat(rs.getDate("RTNTTFSDAT"));
                tntModel.setRtnttel(rs.getString("RTNTTEL"));
                tntModel.setRtntemail(rs.getString("RTNTEMAIL"));
                tntModel.setRtntremrk(rs.getString("RTNTREMRK"));
                tntModel.setRtntstat(rs.getString("RTNTSTAT"));
                tntModel.setRtntcredat(rs.getDate("RTNTCREDAT"));
                tntModel.setRtntupdby(rs.getString("RTNTUPDBY"));
                tntModel.setRtntupddat(rs.getDate("RTNTUPDDAT"));
                model.setTntModel(tntModel);
                
                return model;
            }
        };
        return extractor.extractData(rs);
    }
}
